home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / dbtext.dxr / 00002_Init Layout Screen.ls < prev    next >
Encoding:
Text File  |  2000-01-18  |  4.4 KB  |  126 lines

  1. global gDBTextVarList
  2.  
  3. on InitLayOut
  4.   MyObj = getaProp(gDBTextVarList, GetObjProp())
  5.   ShowTitle()
  6.   EnableScroll = ShowText()
  7.   InitScroll()
  8.   InitButtons(EnableScroll)
  9.   updateStage()
  10.   SetScrollHandler()
  11.   InitRollOverText(MyObj)
  12. end
  13.  
  14. on ShowTitle
  15.   MyObj = getaProp(gDBTextVarList, GetObjProp())
  16.   SpriteList = GetSpriteList(MyObj)
  17.   TitleSprite = getaProp(SpriteList, #title)
  18.   xMember = member("title f")
  19.   puppetSprite(TitleSprite, 1)
  20.   set the textHeight of member xMember to 14
  21.   set the member of sprite TitleSprite to xMember
  22.   xLoc = point(20, 5)
  23.   if the machineType = 256 then
  24.     set the loc of sprite TitleSprite to xLoc + point(0, -1)
  25.   else
  26.     set the loc of sprite TitleSprite to xLoc
  27.   end if
  28. end
  29.  
  30. on ShowText
  31.   MyObj = getaProp(gDBTextVarList, GetObjProp())
  32.   xMember = GetMemberNum(MyObj)
  33.   EnableScroll = 0
  34.   SpriteList = GetSpriteList(MyObj)
  35.   TextSprite = getaProp(SpriteList, #text)
  36.   puppetSprite(TextSprite, 1)
  37.   set the member of sprite TextSprite to xMember
  38.   MinRect = GetTextRect(MyObj, 1)
  39.   if the machineType = 256 then
  40.     set the textHeight of member xMember to 14
  41.   end if
  42.   member(xMember).rect = MinRect
  43.   if member(xMember).height > (GetRectHeight(MinRect) + 7) then
  44.     EnableScroll = 1
  45.   end if
  46.   member(xMember).scrollTop = 0
  47.   set the loc of sprite TextSprite to point(getAt(MinRect, 1), getAt(MinRect, 2))
  48.   return EnableScroll
  49. end
  50.  
  51. on CharMap xMember
  52.   if the machineType = 256 then
  53.     if count(the windowList) > 0 then
  54.       FieldFindandReplace(xMember, numToChar(147), QUOTE)
  55.       FieldFindandReplace(xMember, numToChar(148), QUOTE)
  56.       FieldFindandReplace(xMember, numToChar(145), "'")
  57.       FieldFindandReplace(xMember, numToChar(146), "'")
  58.     end if
  59.   end if
  60. end
  61.  
  62. on FieldFindandReplace xMember, FindText, ReplaceText
  63.   xText = member(xMember).text
  64.   PositionList = []
  65.   start = the ticks
  66.   repeat while xText contains FindText
  67.     Pos = offset(FindText, xText)
  68.     append(PositionList, Pos)
  69.     put " " into char Pos of xText
  70.   end repeat
  71.   Jat((the ticks - start) / 60.0)
  72.   start = the ticks
  73.   repeat with xItem in PositionList
  74.     put ReplaceText into char xItem of field xMember
  75.   end repeat
  76.   Jat((the ticks - start) / 60.0)
  77. end
  78.  
  79. on InitScroll
  80.   MyObj = getaProp(gDBTextVarList, GetObjProp())
  81.   ButtonList = GetButtonList(MyObj)
  82.   xMember = GetMemberNum(MyObj)
  83.   InnerRect = GetInsideRect(2)
  84.   TextRect = GetTextRect(MyObj, 1)
  85.   SpriteList = GetSpriteList(MyObj)
  86.   SetPuppetState(SpriteList, 0, 1)
  87.   NArrowSp = getaProp(SpriteList, #NArrow)
  88.   SArrowSp = getaProp(SpriteList, #SArrow)
  89.   ThumbSp = getaProp(SpriteList, #VThumb)
  90.   BedSp = getaProp(SpriteList, #VBed)
  91.   sL = getAt(InnerRect, 3) - the width of sprite NArrowSp
  92.   sT = getAt(TextRect, 2)
  93.   sR = getAt(InnerRect, 3)
  94.   sB = getAt(InnerRect, 4)
  95.   set the rect of sprite BedSp to rect(sL, sT, sR, sB)
  96.   set the rect of sprite NArrowSp to rect(sL, sT, sR, sT + the height of sprite NArrowSp)
  97.   set the rect of sprite SArrowSp to rect(sL, sB - the height of sprite SArrowSp, sR, sB)
  98.   ThumbXLoc = sL + (the width of sprite NArrowSp / 2)
  99.   ThumbMin = sT + the height of sprite NArrowSp - 2 + (the height of sprite ThumbSp / 2)
  100.   ThumbMax = sB - the height of sprite SArrowSp - (the height of sprite ThumbSp / 2)
  101.   set the loc of sprite ThumbSp to point(ThumbXLoc, ThumbMin)
  102.   MinRect = GetTextRect(MyObj, 1)
  103.   numLines = member(xMember).lineCount
  104.   numVisLines = GetRectHeight(MinRect) / the textHeight of member xMember
  105.   numSettings = numLines - numVisLines + 1
  106.   addProp(ButtonList, ThumbSp, new(script("scroll Thumb subclass"), "v scroll", "global", ThumbSp, ThumbXLoc, ThumbMin, ThumbMax, 1, numSettings, 1, numSettings, 0, 0, #downOrRight))
  107.   Slider = getaProp(ButtonList, ThumbSp)
  108.   addProp(ButtonList, BedSp, new(script("scroll bed subclass"), "v scroll", "global", BedSp, RectToLoc(rect(sL, sT, sR, sB)), Slider, 15))
  109.   addProp(ButtonList, NArrowSp, new(script("scroll button"), "scrollup", "global", NArrowSp, the loc of sprite NArrowSp, Slider, 0))
  110.   addProp(ButtonList, SArrowSp, new(script("scroll button"), "scrolldown", "global", SArrowSp, the loc of sprite SArrowSp, Slider, 1))
  111.   SetButtonList(MyObj, ButtonList)
  112. end
  113.  
  114. on SetScrollHandler
  115.   MyObj = getaProp(gDBTextVarList, GetObjProp())
  116.   init(MyObj)
  117. end
  118.  
  119. on GetInsideRect xSprite, xRect
  120.   if voidp(xRect) then
  121.     xRect = the rect of sprite xSprite
  122.   end if
  123.   xLineSize = the lineSize of sprite xSprite
  124.   return xRect + rect(xLineSize, xLineSize, -xLineSize, -xLineSize)
  125. end
  126.